import service from '@/utils/request'

export const dictApiList = (name: string) => {
	if(name=='type.page'){
		return '/sys/dict/type/list';
	}else if(name=='type.delete'){
		return '/sys/dict/type/del';
	}else if(name=='data.page'){
		return '/sys/dict/data/list';
	}else if(name=='data.delete'){
		return '/sys/dict/data/del';
	}else if(name=='type.sql'){
		return '/sys/dict/type/sql';
	}
	return "";
}

export const useDictTypeAllApi = () => {
	return service.get('/sys/dict/type/all')
}

export const useDictTypeApi = (id: Number) => {
	return service.get('/sys/dict/type/get?ids=' + id)
}

export const useDictTypeSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.post('/sys/dict/type/edit', dataForm)
	} else {
		return service.post('/sys/dict/type/add', dataForm)
	}
}

export const useDictDataApi = (id: Number) => {
	return service.get('/sys/dict/data/get?ids=' + id)
}

export const useDictDataSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.post('/sys/dict/data/edit', dataForm)
	} else {
		return service.post('/sys/dict/data/add', dataForm)
	}
}
